package com.guli.mall.wms.mapper;

import com.guli.mall.wms.entity.WareSkuEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 商品库存
 * 
 * @author 罗俊华
 * @email 1007052116@qq.com
 * @date 2020-09-29 21:37:28
 */
//@Mapper
public interface WareSkuMapper extends BaseMapper<WareSkuEntity> {

    void addStock(@Param("skuId") Long skuId,@Param("wareId") Long wareId,@Param("stock") Integer skuNum);

    /**
     * 获取可用库存数量大于 需要购买sku数量的 库存id
     * @param skuId
     * @param count
     * @return
     */
    List<Long> getWareIdThatHasEnoughStockItem(@Param("skuId") Long skuId, @Param("count") Integer count);


    Integer lockStock(@Param("skuId") Long skuId, @Param("count") Integer count, @Param("wareId") Long wareId);


    Integer unlockStock(@Param("count") Integer count, @Param("skuId") Long skuId, @Param("wareId") Long wareId);

    int deductStockAndDeductStockLocked(@Param("skuNum") Integer skuNum, @Param("skuId") Long skuId, @Param("wareId") Long wareId);
}
